using Microsoft.Phone.Shell;
using System;
using System.Linq;
namespace MicroMsg.Manager
{
	public class TileManager
	{
		public static void SetTileNumber(int nNum)
		{
			if (nNum != 0 && !AccountMgr.isLogin)
			{
				return;
			}
			ShellTile shellTile = Enumerable.First<ShellTile>(ShellTile.get_ActiveTiles());
			if (shellTile != null)
			{
				StandardTileData standardTileData = new StandardTileData();
				standardTileData.set_Count(new int?(nNum));
				StandardTileData standardTileData2 = standardTileData;
				shellTile.Update(standardTileData2);
			}
		}
		public static void SetTileNumberEx(int nNum)
		{
			ShellTile shellTile = Enumerable.First<ShellTile>(ShellTile.get_ActiveTiles());
			if (shellTile != null)
			{
				if (nNum < 0)
				{
					nNum = 0;
				}
				else
				{
					if (nNum > 30)
					{
						nNum = 31;
					}
				}
				string text = "TileIcon/" + nNum + ".png";
				StandardTileData standardTileData = new StandardTileData();
				standardTileData.set_BackgroundImage(new Uri(text, 2));
				standardTileData.set_Count(new int?(0));
				StandardTileData standardTileData2 = standardTileData;
				shellTile.Update(standardTileData2);
			}
		}
		public static void DisplaySencondTile()
		{
			if (Enumerable.FirstOrDefault<ShellTile>(ShellTile.get_ActiveTiles(), (ShellTile shellTile_0) => shellTile_0.get_NavigationUri().ToString().Contains("DefaultTitle=FromTile")) == null)
			{
				StandardTileData standardTileData = new StandardTileData();
				standardTileData.set_Count(new int?(0));
				StandardTileData standardTileData2 = standardTileData;
				ShellTile.Create(null, standardTileData2);
			}
		}
		public static void DeleteSencondTile()
		{
			ShellTile shellTile = Enumerable.FirstOrDefault<ShellTile>(ShellTile.get_ActiveTiles(), (ShellTile shellTile_0) => shellTile_0.get_NavigationUri().ToString().Contains("DefaultTitle=FromTile"));
			if (shellTile != null)
			{
				shellTile.Delete();
			}
		}
		public static void SetSecondTileNumber(int nCount)
		{
			ShellTile shellTile = Enumerable.FirstOrDefault<ShellTile>(ShellTile.get_ActiveTiles(), (ShellTile shellTile_0) => shellTile_0.get_NavigationUri().ToString().Contains("DefaultTitle=FromTile"));
			if (shellTile != null)
			{
				StandardTileData standardTileData = new StandardTileData();
				standardTileData.set_Count(new int?(nCount));
				StandardTileData standardTileData2 = standardTileData;
				shellTile.Update(standardTileData2);
			}
		}
		public static void CreateApplicationTile()
		{
		}
	}
}
